<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>函数式组件使用props</title>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>
    <script src="../js/prop-types.js"></script>
  </head>
  <body>
    <div id="app"></div>
    <script type="text/babel">
      function Person(props) {
        const { name, age, gender } = props;
        return (
          <ul>
            <li>name: {name}</li>
            <li>age: {age}</li>
            <li>gender: {gender}</li>
          </ul>
        );
      }

      Person.propTypes = {
        name: PropTypes.string.isRequired,
        age: PropTypes.number,
        gender: PropTypes.string,
      };

      Person.defaultProps = {
          name: 'dafaultName'
      }

      const data = {
        age: "66",
        gender: "unkonwn",
      };

      ReactDOM.render(<Person {...data} />, document.querySelector("#app"));
    </script>
  </body>
</html>
